<?php /* Smarty version 2.6.26, created on 2018-07-25 15:06:34
         compiled from E:%5CWWW%5C40.125.208.171%5Cvweb/member%5Ctemplates/address/edit.html */ ?>
<style type="text/css"> 
table.etable tr td select{ float:left; }
table.etable tr td em{ font-style:inherit; padding:10px 0 0 10px; color:#FF0000; float:left;}
</style>
<table class="etable">
	<tr>
		<td width="90">姓名：</td>
		<td><input type="text" name="name" id="recive_name" size="38" value="<?php echo $this->_tpl_vars['row']['name']; ?>
" placeholder="收件人姓名"/><em>*</em></td>
	</tr>
	<tr>
		<td>手机：</td> 
		<td><input type="text" name="mobile" id="recive_mobile" size="38" value="<?php echo $this->_tpl_vars['row']['mobile']; ?>
" placeholder="收件人联系电话"/><em>*</em></td>
	</tr>
	<tr>
		<td>地区：</td>
		<td><div class="area_box"></div></td>
	</tr>
	<tr>
		<td>地址：</td>
		<td><input type="text" name=""  id="recive_address" size="38" value="<?php echo $this->_tpl_vars['row']['address']; ?>
" placeholder="收件人详细地址"/><em>*</em></td>
	</tr>
	<tr>
		<td>邮编：</td>
		<td><input type="text" name="" id="recive_zip" size="38" value="<?php echo $this->_tpl_vars['row']['zip']; ?>
" placeholder="收件人邮编"/></td>
	</tr>
	<tr>
		<td>默认：</td>
		<td><input type="checkbox" id="recive_is_default" <?php if ($this->_tpl_vars['row']['is_default'] == '1'): ?>checked="checked"<?php endif; ?> name="is_default" value="1"/></td>
	</tr> 
</table> 
<script type="text/javascript" src="<?php echo $this->_tpl_vars['__PUBLIC__']; ?>
js/area.js"></script>
<script type="text/javascript">
	<?php if ($this->_tpl_vars['row']['prov'] == '' && $this->_tpl_vars['row']['city'] == '' && $this->_tpl_vars['row']['dist'] == ''): ?>
		$(".area_box").area();
	<?php else: ?>
		$(".area_box").area({ 
			'prov':'<?php echo $this->_tpl_vars['row']['prov']; ?>
',
			'city':'<?php echo $this->_tpl_vars['row']['city']; ?>
',
			'dist':'<?php echo $this->_tpl_vars['row']['dist']; ?>
'
		});	
	<?php endif; ?> 
	function ajax_submit(){ 
		var name = $("#recive_name").val(); 		if(name == '')	{ 	alert('姓名不能为空！');	return false; }
		var mobile = $("#recive_mobile").val();		if(mobile == ''){ 	alert('电话不能为空！');	return false; }
		var prov = $("#prov").val();		if(dist == '0')	{ 	alert('选择省份！');		return false; } 
		var city = $("#city").val();		if(city == '0')	{ 	alert('选择市区！');		return false; } 
		var dist = $("#dist").val(); 		if(dist == '0')	{ 	alert('选择县级！');		return false; } 
		var address = $("#recive_address").val();	if(address == ''){ 	alert('地址不能为空！');	return false; } 
		var zip = $("#recive_zip").val(); 
		if(zip){
			if(!/^[0-9][0-9]{5}$/.test(zip)){ 
				$.alert('邮编格式不正确！');  
				return false; 
			}
		} 
		var is_default = $("#recive_is_default").is(':checked')?'1':'0'; 
		$.post('member.php?m=address&a=edit_save',{<?php if ($this->_tpl_vars['row']['id']): ?>id:<?php echo $this->_tpl_vars['row']['id']; ?>
,<?php endif; ?>name:name,mobile:mobile,prov:prov,city:city,dist:dist,address:address, zip:zip, is_default:is_default},function(result){ 
			var data = jQuery.parseJSON(result); 
			if(data.error =='0'){
				<?php if ($_GET['type'] == '1'): ?>
					con_html = '<label>'+
									'<span>送至</span>'+
									'<input type="radio" name="address_id" value="'+data.id+'"/>'+
									'<p>'+data.prov_cn+' '+data.city_cn+' '+data.dist_cn+' '+data.address+' ( '+name+' 收) '+data.mobile+'</p>'+
								'</label>'+
								'<div class="rt">'+ 
									'<a href="javascript:;" addrid="'+data.id+'" onClick="address_edit(\'添加地址\',\'member.php?m=address&a=edit&type=1&id='+data.id+'\')">编辑</a> '+
									'<a href="javascript:;" addrid="'+data.id+'" class="address_del">删除</a> '+
								'</div>'; 
					div_num = $('.addr_box').length;
					if(div_num == '0'){ 
						$(".addr_box").html('<div class="addr_box add_con_'+data.id+'">'+con_html+'</div>'); 
					}else{ 
						<?php if ($this->_tpl_vars['row']['id']): ?>
							$(".add_con_"+data.id).html(con_html);  
						<?php else: ?>
							$(".add_con:last-child").after('<div class="addr_box add_con_'+data.id+'">'+con_html+'</div>');
						<?php endif; ?>
					} 
					$('.add_con_'+data.id+' input[name=address_id]').attr("checked","checked"); 
					ajax_close(); 
				<?php else: ?>
					$.alert('保存成功', function(){
						location.reload(); 
					});
				<?php endif; ?>
			}else{
				$.alert(data.msg);
			} 
		}); 
	}
</script>